//
//  HOMInvocationBuilder.m
//  HigherOrderMessaging
//
//  Created by Ofri Wolfus on 02/12/06.
//  Copyright 2006 Ofri Wolfus. All rights reserved.
//

#import "HOMInvocationBuilder.h"
#import "DPObjCRuntime.h"


@implementation HOMInvocationBuilder

+ (void)initialize {
	Method m = class_getInstanceMethod([NSProxy class], @selector(forward::));
	method_setImplementation(class_getInstanceMethod(self, @selector(forward::)),
							 method_getImplementation(m));
}

+ (id)builderForTarget:(id)t {
	HOMInvocationBuilder *b = class_createInstance(self, 0);
	b->target = t;
	return b;
}

- (id)forward:(SEL)sel :(void *)marg_list {
	return nil;
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
	return [target methodSignatureForSelector:sel];
}

- (void)forwardInvocation:(NSInvocation *)invoc {
	NSInvocation *i = [[invoc copy] autorelease];
	[invoc setReturnValue:&i];
}

- (void)dealloc {
	object_dispose(self);
}

@end
